﻿/*======================================================================
== Copyright : BlueCurve (c)
== Licence   : Gnu/GPL v2.x
== Author    : Teddy Albina
== Email     : bluecurveteam@gmail.com
== Web site  : http://www.codeplex.com/BlueCurve
========================================================================*/
using System;
using System.AddIn;
using System.AddIn.Pipeline;
using System.Security.Cryptography.X509Certificates;
using BlueCurve.AddinView;
using BlueCurve.DownloadAttributes;
using BlueCurve.IndexationContract;
using BlueCurve.Plugins;
using BlueCurve.WebCrawlerRequest;

namespace BlueCurve.AddinAdapters
{
    /// <summary>
    /// Adapteur coté addin pour les plugins de type fichier
    /// </summary>
    [AddInAdapter]
    public class AddinAdapterToAddinFile : ContractBase, IFile
    {
        private AddinFileViewAddinsSide _view;

        public AddinAdapterToAddinFile(AddinFileViewAddinsSide view)
        {
            this._view = view;
        }

        #region IFile Membres

        public IndexationData IndexerLoader(RequestState requeststate, string location)
        {
            return this._view.IndexerLoader(requeststate, location);
        }

        #endregion
    }

    /// <summary>
    /// Adapteur coté addin pour les plugins de type protocol
    /// </summary>
    [AddInAdapter]
    public class AddinAdapterToAddinProtocol : ContractBase, IProtocol
    {
        private AddinProtocolViewAddinsSide _view;

        public AddinAdapterToAddinProtocol(AddinProtocolViewAddinsSide view)
        {
            this._view = view;
        }

        #region IProtocol Membres

        public string Accept
        {
            get
            {
                return this._view.Accept;
            }
            set
            {
                this._view.Accept = value;
            }
        }

        public RequestState Download(Attributes downloadata, X509Certificate[] certificates, X509Certificate[] certificates2)
        {
            return this._view.Download(downloadata, certificates, certificates2);
        }

        public Uri Proxy
        {
            get
            {
                return this._view.Proxy;
            }
            set
            {
                this._view.Proxy = value;
            }
        }

        #endregion
    }
}
